@extends('layouts.admin')

@section('title', ($ranking->id ? '编辑' : '新建'))

@section('content_header')
    <h2>

    </h2>
@stop

@section('content')
    @include('admin.common.message')
    @if($ranking->id)
        <form id="form" class="subject-form image-upload-form form-horizontal" method="post"
      action="{{ route('admin.ranking.update', $ranking->id) }}">
    {{ method_field('PATCH') }}
    @else
        <form id="form" class="subject-form image-upload-form form-horizontal" method="post"
              action="{{ route('admin.ranking.store') }}">
    @endif
        {{ csrf_field() }}
        <div class="form-group{{$errors->has('name') ? ' has-error' : ''}}">
            <label for="" class="col-sm-2 control-label">名称</label>
            <div class="col-sm-10">
                <input type="text" name="name" class="form-control" id="" placeholder=""
                       value="{{ old('name', $ranking->name) }}">
                @if($errors->has('name'))
                    <small class="help-block">{{ $errors->first('name') }}</small>
                @endif
            </div>
        </div>

        <div class="form-group{{$errors->has('object_type') ? ' has-error' : ''}}">
            <label for="" class="col-sm-2 control-label">
                内容类型
            </label>
            <div class="col-sm-10">
                <select name="object_type" class="form-control" id="">
                    @foreach($ranking->listObjectTypes() as $type => $typeValue)
                    <option value="{{ $type }}" @if($ranking->object_type == $type) selected @endif>{{ $typeValue['name'] }}</option>
                    @endforeach
                </select>
                @if($errors->has('object_type'))
                    <small class="help-block">{{ $errors->first('object_type') }}</small>
                @endif
            </div>
        </div>


        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10 text-center">
                <input type="submit" value="提交" class="btn btn-primary">
            </div>
        </div>
    </form>
@stop



